import request from '@/utils/request';
import { PageResponse } from '@/interface/pages';

/**
 * 获取分页列表
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getRoleList = (params: API.role.PageListDto) => {
  return request<PageResponse<API.role.EntitySchema[]>>({
    url: '/admin/role',
    method: 'get',
    params
  });
};

/**
 * 获取所有列表 - 用于selectbox
 *
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const getRoleAll = () => {
  return request<API.role.EntitySchema[]>({
    url: '/admin/role/all',
    method: 'get'
  });
};

/**
 * 添加
 *
 * @param data: Role
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const addRole = (data: any): Promise<any> => {
  return request({
    url: '/admin/role',
    method: 'post',
    data
  });
};

/**
 * 编辑
 *
 * @param id
 * @param data: Role
 * @returns Promise
 *
 * @todo 发起axios请求
 */
export const updateRole = (id: number, data: any): Promise<any> => {
  return request({
    url: '/admin/role/' + id,
    method: 'put',
    data
  });
};

/**
 * 删除
 *
 * @param id
 * @returns
 *
 * @todo 发起axios请求
 */
export const deleteRole = (id: number): Promise<any> => {
  return request({
    url: '/admin/role/' + id,
    method: 'delete'
  });
};
